import ResManager from "../manager/ResManager";

const {ccclass, property} = cc._decorator;
export enum UILayer {
    Base,
    Fight,
    Pop,
    Notice,
    Loading
}

/**
 * UI窗体层级装饰器
 * 层级高的窗体遮挡层级低的窗体
 * @param level 路径
 */
export function uiLevel(level: UILayer) {
    return function (target: Function) {
        target.prototype._level = level;
    };
}
@ccclass
export class UIView extends cc.Component {

    @property(cc.Widget)
    content: cc.Widget = null;
    @property(cc.Node)
    adNode: cc.Node = null;
    /** 界面id */

    private static _level: UILayer;

    public UIid: number = 0;
    
    public static get level(){
        return this._level;
    }
    public get isOpen(): boolean {
        return this.node.active;
    }

    public set isOpen(active) {
        if (this.node.active == active)
            return;
        this.node.active = active;
    }

    public onOpen(...args): void {

    }

    public onClose(): any {
    }

    public onDestroy() {
        ResManager.instance.release(this.node._prefab.asset);
    }
}
